#ifndef NIVEL_H_
#define NIVEL_H_

#include "includes.h"
#include "Aritmetico.cpp"
#include "Nivel.h"

Nivel::Nivel(unsigned short idnivel) {
	this -> id = idnivel;
	this -> compresor = new AritmeticoCompress();
	uInt i;
	
	// Inicializamos los caracteres
	switch (id) {
		
		case (0):
			caracteres.push_back(0);
			break;
		case (1):
			caracteres.push_back(1);
			break;
		case (2):
			caracteres.push_back(2);
			caracteres.push_back(3);
			break;
		case (3):
			for (i = 4; i <= 7; i++) {
				caracteres.push_back(i);
			}
			break;
		case (4):
			for (i = 8; i <= 15; i++) {
				caracteres.push_back(i);
			}
			break;
		case (5):
			for (i = 16; i <= 31; i++) {
				caracteres.push_back((uChar)i);
			}
			break;
		case (6):
			for (i = 32; i <= 63; i++) {
				caracteres.push_back(i);
			}
			break;
		case (7):
			for (i = 64; i <= 127; i++) {
				caracteres.push_back(i);
			}
			break;
		case (8):
			for (i = 128; i <= 255; i++) {
				caracteres.push_back(i);
			}
			break;
		default:
			break;
	}
	
}

void Nivel::getSalidaComprimida(string* salidaComprimida, bool completarAbyte) {
	this->compresor->getSalidaComprimida(salidaComprimida, completarAbyte);
}

Nivel::~Nivel() {
	delete (this->compresor);
}

bool Nivel::tieneCaracter(const uChar c) {
	vector<uChar>::iterator iter = find(this->caracteres.begin(), this->caracteres.end(), c);
	if (iter != this->caracteres.end() ) {
		return true;
	} 
	else {
		return false;
	}
}

void Nivel::comprimirChar( char c, bool isLastChar = false) {
	this->compresor->compressChar(c, isLastChar);
}

#endif	/* NIVEL_H */

